﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.WebPage;

namespace ZHDJ.Web.Portal.Grassroots
{
    public partial class Default : PortalPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        #region 地图显示
        public string smallImg = "<img src=\"{0}\" id='{5}' class='familyImgSma familyImgTip' " +
                                   "style=\"width:{1}px;position:absolute;top:{2}px;left:{3}px;\" title='{4}'/>";
        public string imgTip = @"<div id='C{0}' class='familyImgC' title='{1}'>
                <div class='GrassGruop' style='min-width: 150px'>
                    <ul>
                        {2}
                    </ul>
                </div>
            </div>";
        public string li = " <li><a  href='ItemDetail.aspx?ItemID={0}' target='_blank'>{1}</a></li>";
        public void LoadData()
        {
            StringBuilder sbImg = new StringBuilder();
            StringBuilder sbImgC = new StringBuilder();
           
            var group = DB.PartyGrassrootsGroups.Where(a => a.State == 4).ToList();
            foreach (var g in group)
            {
                var ImgUrl = "../../Resource/themes/default/images/OrganisationDepartment/GroupImage.png";
                sbImg.AppendFormat(smallImg, ImgUrl, g.GroupName, g.CssPointY, g.CssPointX, g.GroupName, g.ID);
                var itemList = DB.PartyGrassrootsGroupItems.Where(a => a.State == 4 && a.GroupID == g.ID);
                StringBuilder sbli = new StringBuilder();
                foreach (var item in itemList)
                {
                    sbli.AppendFormat(li, item.ID,item.ItemName);
                }
                sbImgC.AppendFormat(imgTip, g.ID,g.GroupName, sbli);

            }
            familyImg.Text = sbImg.ToString()+ sbImgC.ToString();
        }
        #endregion
    }
}